<% layout('/layouts/default.html', {title: '平台参数管理', libs: ['ueditor','validate']}){ %>
<div class="main-content">
	<div class="">
		<div class="box-header with-border">
			<div class="box-title">
				<i class="fa icon-note"></i>平台参数设置
			</div>
			<div class="box-tools pull-right">
				<button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
			</div>
		</div>
		<% for( item in list){ %>
			<% if(item.type=="1"){ %>
				<div class="box-body">
					<div class="row">
						<div class="col-xs-12">
							<div class="form-group">
								<label class="control-label col-xs-4" title="">
									<span class="required hide">*</span> ${item.paramName}：<i class="fa icon-question hide"></i>
								</label>
								<div class="col-sm-4">
									<#form:input id="${item.paramKey}" value="${item.paramValue}" class="form-control"/>
								</div>
								<button  class="btn btn-primary" data-id="${item.id}" data-key="${item.paramKey}" onclick="save(this)">${text('保 存')}</button>&nbsp;
							</div>
						</div>
					</div>
				</div>
			<%}else if(item.type=="3"){ %>
			<div class="box-body">
				<div class="row">
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-xs-4" title="">
								<span class="required hide">*</span> ${item.paramName}：<i class="fa icon-question hide"></i>
							</label>
							<div class="col-sm-4">
								<#form:select id="${item.paramKey}" value="${item.paramValue}" dictType="${item.dictType}" class="form-control"/>
							</div>
							<button  class="btn btn-primary" data-id="${item.id}" data-key="${item.paramKey}" onclick="save(this)">${text('保 存')}</button>&nbsp;
						</div>
					</div>
				</div>
			</div>
			<% }else if(item.type=="2"){ %>
				<div  class="box-body">
					<#form:form id="${item.paramKey}inputForm" action="${ctx}/pt/ptSetting/save" method="post">
						<div class="row">
							<div class="col-xs-12">
								<div class="form-group">
									<#form:hidden name="id" value="${item.id}"/>
									<label class="control-label col-xs-4" title="">
										<span class="required hide">*</span> ${item.paramName}：<i class="fa icon-question hide"></i>
									</label>
									<div class="col-sm-6">
										<#form:ueditor id="${item.paramKey}" name="paramValue" value="${item.paramValue}" maxlength="1000" height="200" class=""
										simpleToolbars="false" readonly="false" outline="false"/>
									</div>
									<button  class="btn btn-primary" data-id="${item.id}" data-key="${item.paramKey}" onclick="saveFrom('${item.paramKey}')">${text('保 存')}</button>&nbsp;
								</div>
							</div>
						</div>
					</#form:form>
				</div>
			<% } %>
		<% } %>
	</div>
</div>
<% } %>
<script>
	function save(obj){
		var id = $(obj).data("id");
		var key = $(obj).data("key");
		var val = $("#"+key).val();
		$.post("${ctx}/pt/ptSetting/save",{id,paramValue:val},function (res){
			if(res.result=="true"){
				js.showMessage("修改成功","","success");
			}else{
				js.showErrorMessage(res.message);
			}
		})
	}

</script>

<script>
	function saveFrom(id){
		$("#"+id+"inputForm").validate({
			submitHandler: function(form){
				js.ajaxSubmitForm($(form), function(data){
					js.showMessage(data.message);

				}, "json");
			}
		});
	}

</script>